package cn.tedu.store.commons.pojo.user.dto;

import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * 用户注册DTO类
 *
 * @author RelentlessFlow
 * @version 0.0.1
 */
@Data
public class UserRegistryDTO implements Serializable {

    private static final String REGEXP_USER_USERNAME = "^[a-zA-Z]{1}[0-9a-zA-Z]{3,15}$";
    private static final String MESSAGE_USER_USERNAME = "用户名必须是由字母、数字组成的4~16字符，且第1个字符必须是字母！";

    private static final String REGEXP_USER_PASSWORD = "^[\\u0020-\\u007e]{4,16}$";
    private static final String MESSAGE_USER_PASSWORD = "密码的长度必须是4~16位！";

    private static final String REGEXP_USER_PHONE = "^1[34589][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]$";
    private static final String MESSAGE_USER_PHONE = "请填写正确的手机号！";

    private static final String REGEXP_USER_EMAIL = "^[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+(\\.[a-zA-Z0-9_-]+)+$";
    private static final String MESSAGE_USER_EMAIL = "请填写正确格式的邮箱！";

    private static final String VALIDATE_MESSAGE_PREFIX = "注册用户失败，";

    @ApiModelProperty(value="用户名",name="username",required = true,example = "liubei")
    @NotNull(message = VALIDATE_MESSAGE_PREFIX + "请填写用户名！")
    @Pattern(regexp = REGEXP_USER_USERNAME, message = VALIDATE_MESSAGE_PREFIX + MESSAGE_USER_USERNAME)
    private String username;

    @ApiModelProperty(value="昵称",name="nickname",required = true,example = "法外狂徒")
    @NotNull(message = VALIDATE_MESSAGE_PREFIX + "请填写昵称！")
    private String nickname;

    @ApiModelProperty(value="用户邮箱",name="email",required = false,example = "20545465456@qq.com")
    @Pattern(regexp = REGEXP_USER_EMAIL, message = VALIDATE_MESSAGE_PREFIX + MESSAGE_USER_EMAIL)
    private String email;

    @ApiModelProperty(value="移动电话",name="phone",required = true,example = "12345678901")
    @NotNull(message = VALIDATE_MESSAGE_PREFIX + "请填写手机号！")
    @Pattern(regexp = REGEXP_USER_PHONE, message = VALIDATE_MESSAGE_PREFIX + MESSAGE_USER_PHONE)
    private String phone;

    @ApiModelProperty(value="密码",name="password",required = true,example = "123asdf")
    @NotNull(message = VALIDATE_MESSAGE_PREFIX + "请填写密码！")
    @Pattern(regexp = REGEXP_USER_PASSWORD, message = VALIDATE_MESSAGE_PREFIX + MESSAGE_USER_PASSWORD)
    private String password;

    @ApiModelProperty(value="确认密码",name="ackPassword",required = true,example = "123asdf")
    @NotNull(message = VALIDATE_MESSAGE_PREFIX + "请填写确认密码！")
    @Pattern(regexp = REGEXP_USER_PASSWORD, message = VALIDATE_MESSAGE_PREFIX + MESSAGE_USER_PASSWORD)
    private String ackPassword;
}
